package com.itheima.zuoye.zuoye2;

import java.io.*;
import java.nio.CharBuffer;
import java.nio.file.Files;
import java.nio.file.Paths;

public class Test {
    public static void main(String[] args) {
        try (
                FileReader fr = new FileReader("day14_IO\\src\\com\\itheima\\zuoye\\zuoye2\\sum.txt");
                BufferedReader br = new BufferedReader(fr);

        ) {

            String num = br.readLine();

            int sum = Integer.parseInt(num);
            FileWriter fw = new FileWriter("day14_IO\\src\\com\\itheima\\zuoye\\zuoye2\\sum.txt");
            BufferedWriter bw = new BufferedWriter(fw);
            if (sum <= 3){
                System.out.println("您还有"+ sum + "次免费使用机会");
                sum++;
                bw.write(sum+"");
                fw.close();
                bw.close();
            }else {
                System.out.println("您的免费次数已用尽，请充值");

            }
        } catch (Exception e){
            throw new RuntimeException(e);
        }
        }
    }

